package com.book.service;


import com.book.dao.noticeDao;
import com.book.po.notice;
import com.book.po.s_n;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class noticeService {

    @Autowired
    private com.book.dao.noticeDao noticeDao;

    public List<notice> notice_select(String sid){
        List<s_n> ss = new ArrayList<>();
        List<notice> notices = new ArrayList<>();
        ss = noticeDao.notice_select(sid);
        for(int i = 0;i<ss.size();i++){
            s_n s_n = new s_n();
            s_n = ss.get(i);
            notice notice = noticeDao.notice_detial(s_n.getNid());
            notice.setSign(s_n.getSign());
            notices.add(notice);
        }
        return notices;
    };

    public int notice_count(String sid){

        int count = noticeDao.notice_count(sid);
        return count;
    };
//    public String book_insert(Book book){
//        if (bookDao.book_insert(book)!=0){
//            return "添加成功";
//        }else {
//            return "添加失败";
//        }
//    };
//
//    public String book_delete(Integer bookId){
//        if (bookDao.book_delete(bookId)!=0){
//            return "删除成功";
//        }else {
//            return "删除失败";
//        }
//    }
//
    public String sign_update(s_n s_n){
        if (noticeDao.sign_update(s_n)!=0){
            return "修改成功";
        }else {
            return "修改失败";
        }
    }
}
